#ifndef LIDARCLIENT_H
#define LIDARCLIENT_H

#include <QObject>
#include <QDebug>

#include <grpcpp/grpcpp.h>
// #include <grpc/grpc.h>
#include <grpcpp/channel.h>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h>

#include "lidar.pb.h"
#include "lidar.grpc.pb.h"


class LidarClient:public QObject
{
    Q_OBJECT
public:
    LidarClient(std::shared_ptr<grpc::Channel> channel, QObject *parent = nullptr);
    ~LidarClient();

    //请求激光雷达设备当前运行信息
    const QSharedPointer<lidar::RuntimeParamsPackage> getPMTState(const ::lidar::GUID request);
    //
    bool setLaser(const ::lidar::LaserLD request);
    //
    bool setRocMoveToAngle(const ::lidar::RocMovePara request);
    //启动雷达采集
    const QSharedPointer<lidar::XError> startAcquire(const ::lidar::AcquireParamsPackage request);
    //停止雷达采集
    bool stopAcquire(const ::lidar::GUID request);
    //获取雷达解算数据
    const QSharedPointer<lidar::ComputedResult> getNextComputerData(const ::lidar::AlgrithmParamsPackage request);
    //开始查询时间范围内的雷达解算数据
    bool compute(const ::lidar::ComputeParamsPackage request);
    const QSharedPointer<lidar::LidarRawData> getNextData(const lidar::GUID request);
    bool beginQueryData(const lidar::RawParamsPackage request );



    //
    const QSharedPointer<lidar::LaserStatus> getLaserStatus(const ::lidar::GUID request);

signals:
    //定义信号
    void Sig_GetPMTState(const QSharedPointer<::lidar::RuntimeParamsPackage>);
    void Sig_StartAcquire(const QSharedPointer<lidar::XError>);
    void Sig_GetNextComputeData(const QSharedPointer<lidar::ComputedResult>);
    void Sig_GetNextData(const QSharedPointer<lidar::LidarRawData> );


private:
    grpc::CompletionQueue m_cq;
    //存根，使用m_stub调用grpc接口
    std::unique_ptr<lidar::PMT::Stub> m_stub;

};

class AsyncClientCall{
public:
    AsyncClientCall(){};

    grpc::ClientContext m_context;
};

#endif // LIDARCLIENT_H
